﻿using LPLS.DBEntities;
using LPLS.DBInterface;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LPLS.DBServices
{
   public abstract class DBBaseService: IDBBaseInterface
    {
      public DBContext DbContext { get; set; }

        public DBBaseService(DBContext dbContext) {

            DbContext = dbContext;
            InitDataBaseName();
            Client = DbContext.GetDbContext(DataBaseName);

        }

        /// <summary>
        /// 切换成其他的数据库
        /// </summary>
        /// <param name="databaseName"></param>

        public void  ConfigTempDataBase(string databaseName)
        {
            DataBaseName = databaseName;
            TempClient = DbContext.GetDbContext(DataBaseName);

             
        }
        public SqlSugarScope Client { get; set; }



        public SqlSugarScope TempClient { get; set; }

        public string DataBaseName { get; set; }
       

        public abstract void   InitDataBaseName();
    }
}
